package com.xhb.campusservices.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.oas.annotations.EnableOpenApi;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

import java.util.ArrayList;

@Configuration
@EnableOpenApi
public class SwaggerConfig {
    //配置了Swagger的 Docket Bean实例
    @Bean
    public Docket docket() {
//        return new Docket(DocumentationType.SWAGGER_2);
        return new Docket(DocumentationType.OAS_30)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.xhb.campusservices.controller"))
                //项目上线，只显示登录接口
                .paths(PathSelectors.ant("/loginM/login"))
                .build();
    }

    //配置Swagger信息 = apiInfo
    private ApiInfo apiInfo() {
        //作者信息
        Contact contact = new Contact("三子夏", "", "1102580266@qq.com");
        return new ApiInfo(
                "夏夏的Swagger API文档",
                "过好每一天",
                "1.0",
                "urn:tos",
                contact,
                "Apache 2.0",
                "http://www.apache.org/licenses/LICENSE-2.0",
                new ArrayList());
    }
}
